class MaestriasController < ApplicationController
  layout "menuprincipal"
  before_filter :login_required

  # GET /maestrias
  # GET /maestrias.xml
  def index
    @maestrias = Maestria.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @maestrias }
    end
  end

  # GET /maestrias/1
  # GET /maestrias/1.xml
  def show
    @maestria = Maestria.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @maestria }
    end
  end

  # GET /maestrias/new
  # GET /maestrias/new.xml
  def new
    @maestria = Maestria.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @maestria }
    end
  end

  # GET /maestrias/1/edit
  def edit
    @maestria = Maestria.find(params[:id])
  end

  # POST /maestrias
  # POST /maestrias.xml
  def create
    @maestria = Maestria.new(params[:maestria])

    respond_to do |format|
      if @maestria.save
        flash[:notice] = 'Maestria fue creada satisfactoriamente.'
        format.html { redirect_to(@maestria) }
        format.xml  { render :xml => @maestria, :status => :created, :location => @maestria }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @maestria.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /maestrias/1
  # PUT /maestrias/1.xml
  def update
    @maestria = Maestria.find(params[:id])

    respond_to do |format|
      if @maestria.update_attributes(params[:maestria])
        flash[:notice] = 'Maestria fue actualizada satisfactoriamente.'
        format.html { redirect_to(@maestria) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @maestria.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /maestrias/1
  # DELETE /maestrias/1.xml
  def destroy
    @maestria = Maestria.find(params[:id])
    @maestria.destroy

    respond_to do |format|
      format.html { redirect_to(maestrias_url) }
      format.xml  { head :ok }
    end
  end
end
